#include <stdio.h>
#include<stdlib.h>

typedef char TreeData;
typedef struct TreeNode
{
    TreeData val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

TreeNode* byNode(char x)
{
    if (x == '#') return NULL;
    TreeNode* mid = (TreeNode*)malloc(sizeof(TreeNode));
    mid->val = x;
    mid->left = mid->right = NULL;
    return mid;
}

TreeNode* create(char* arr, int* i)
{
    if (arr[(*i)] == '#')
    {
        (*i)++;
        return NULL;
    }
    TreeNode* root = byNode(arr[(*i)]);
    (*i)++;
    root->left = create(arr, i);
    root->right = create(arr, i);

    return root;
}

void traversal(TreeNode* root)
{
    if (root == NULL) return;
    traversal(root->left);
    printf("%c ", root->val);
    traversal(root->right);

}

int main()
{
    char arr[100];
    scanf("%s", arr);
    int i = 0;
    TreeNode* root = create(arr, &i);
    traversal(root);

    return 0;
}
